package com.jumper.cwolf.test;

import cn.hutool.json.JSONUtil;
import lombok.Builder;
import lombok.Data;

import java.util.*;
import java.util.stream.Collectors;
import java.util.stream.IntStream;
import java.util.stream.Stream;

public class A {
        public static void main(String[] args) {
            Map<String,Integer> map1=new HashMap<>();
            map1.put("A", 100);
            map1.put("B", 200);
            map1.put("C", 44);

            Map<String,Integer> map2=new HashMap<>();
            map2.put("A", 300);
            map2.put("B", 400);
            map2.put("C", 44);

            Map<String,Integer> map3=new HashMap<>();
            map3.put("A", 300);
            map3.put("C", 44);
            map3.put("B", 400);

            List<Map<String,Integer>> list = new ArrayList<>();
            list.add(map1);
            list.add(map2);
            list.add(map3);

            Map<String, Integer> stringIntegerMap = list.stream().reduce((x, y) -> {
                x.forEach((k, v) -> {
                    int vv = y.get(k) + v;
                    x.put(k, vv);
                });
                return x;
            }).get();

            System.out.println(JSONUtil.toJsonStr(stringIntegerMap));


        }

}
